package com.easylinkin.linkappapi.device.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easylinkin.linkappapi.device.entity.WaterRecords;
import com.easylinkin.linkappapi.device.entity.vo.WaterRecordsVo;
import com.easylinkin.linkappapi.device.entity.vo.WaterStatisticsVo;

import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;

import java.io.Serializable;

/**
 * WaterRecords表数据库访问层
 *
 * @author CodeGenerator
 * @date 2022/06/27
 */
public interface WaterRecordsMapper extends BaseMapper<WaterRecords> {


    /**
     * 查询分页
     *
     * @param page        分页参数对象
     * @param appWaterRecords 过滤参数对象
     * @return 查询分页结果
     */
    IPage<WaterRecords> selectPage(Page page, @Param("appWaterRecords") WaterRecordsVo appWaterRecords);

    /**
     * 查询单条
     *
     * @param id 主键id
     * @return 查询结果
     */
    WaterRecords getOneById(@Param("id") Serializable id);

    /**
     * 查询用水记录
     *
     * @param deviceCode 设备号
     * @return
     */
    List<WaterRecords> findByDeviceCode(WaterRecordsVo appWaterRecords);

    /**
     * 按时间用水量统计
     *
     * @param appWaterRecords
     * @return
     */
    Double getSumWaterByTime(WaterRecordsVo appWaterRecords);

    /**
     * 日均用水量统计
     *
     * @param appWaterRecords
     * @return
     */
    Double getAvgDayWater(WaterRecordsVo appWaterRecords);

    /**
     * 查询最新一条记录
     * @param waterRecordsVo
     * @return
     */
    WaterRecords getLatestRecord(WaterRecordsVo waterRecordsVo);

    /**
     * 按时间查询用水量统计趋势图
     * @param waterRecordsVo
     * @return
     */
    List<WaterStatisticsVo> getWaterStatisticsVoByDay(WaterRecordsVo waterRecordsVo);

    /**
     * 按月份统计一级区域用水量
     * @param tenantId
     * @param time
     * @return
     */
    List<WaterRecordsVo> findOneArea(@Param("tenantId") String tenantId, @Param("time") Date time);
}

